
function [zl,lc]= leel(ntotal,nleja,r)


% Leja points for scaled ellipse (Huisinga article).

%r is the parameter of the ellipse determined by the ratio
%  between axis (r=0 -> scaled circle).
% nleja number of Leja points to be generated.
% ntotal number of points (randomly) generated.
% zt,zl leja points (disorder and order points).
% dzt keep the product of distances between points.
 % r,theta parameters of the 'shape' (ellipse).
% kr, dmax variables to choose the first Leja point.
% dist function... distance between two points.
% zpoly function evaluates (z-zl_1)...(z-zl_n)
% lc logarithmic capacity.
 
% Generation of initial points (even spaced points in the circle).

      [zt,theta] =  cpoints(ntotal,r);
           

% Leja points algorithm. First point...
% (its the point max|zt|).


      [dmax,kr] = max(abs(zt));
      zl(1)=zt(kr);     
      it=1;

% Rest of points...
   dzt(1:ntotal) = 0.;
      while (it < nleja)
% input: it leja points.
         [dzt,zl,it] = cpleja(it,ntotal,nleja,zt,zl,dzt);
% output: it=it+1 leja points.
      end

% Checking logarithmic capacity...
% Estimating it...
% WARNING: this estimation seems to work only for very 
% large nleja(>> 500).

         zlc=zpoly(it-1,zl(it),nleja,zl);
         lc=sqrt(abs(zlc)^2);
         lc=(lc)^(1.d0/(it));

      end


